#include<bits/stdc++.h>
using namespace std;
const int N=1e5+2;
long long T,n,m,L,V2,d[N],v2[N],a[N],p[N],ans,su;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&T);
    for(long long i=1;i<=T;i++){
        ans=0;
        scanf("%lld%lld%lld%lld",&n,&m,&L,&V2);
        V2*=V2;
        for(long long i=1;i<=n;i++){
            scanf("%lld%lld%lld",&d[i],&v2[i],&a[i]);
            v2[i]*=v2[i];
        }
        for(long long i=1;i<=m;i++){
            scanf("%lld",&p[i]);
        }
        for(long long j=1;j<=n;j++){
            long long vt2=v2[j]+2*a[j]*(p[m]-d[j]);
            if(vt2>V2&&d[j]<=p[m]){
                ans++;
            }
        }
        if(ans==0)su=m;
        else su=m-1;
        printf("%lld %lld\n",ans,su);
    }
    return 0;
}
